<?php

use richardfan\widget\JSRegister;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\DdModulesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Dd Modules';
$this->params['breadcrumbs'][] = $this->title;
?>
<ul class="nav nav-tabs">
    <li>
        <?= Html::a('添加 Dd Modules', ['create'], ['class' => '']) ?>
    </li>
    <li class="active">
        <?= Html::a('Dd Modules管理', ['index'], ['class' => 'btn btn-primary']) ?>
    </li>
</ul>
<div class="firetech-main"  style="margin-top:20px;">

    <div class="dd-modules-index ">
        <?php // echo $this->render('_search', ['model' => $searchModel]); 
        ?>
        <div class="panel panel-default">
            <div class="box-body">
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel' => $searchModel,
                    'columns' => [
                        'logo' => [
                            'attribute' => 'logo',
                            'format' => ['raw'],
                            'value' => function ($model) {
                                $images = $model->logo;
                                $html = '<div class="media" style="width:240px;">
                                            <div class="media-left media-middle">
                                                <a href="#">
                                                <img class="media-object" src="' . common\components\Upload::tomdia($images) . '" alt="...">
                                                </a>
                                            </div>
                                            <div class="media-body">
                                                <h4 class="media-heading">' . $model->title . '</h4>
                                                <p>' . $model->ability . '</p>   
                                            </div>
                                            </div>';
                                return $html;
                                // return $ai_group_status;
                                // return Html::img(common\components\Upload::tomdia($images), ['width' => 100, 'height' => 'auto']);
                            }
                        ],
                        // 'mid',
                        // 'name',
                        'type',
                        'title',
                        'version',
                        //'ability',
                        //'description',
                        'author',
                        //'url:url',
                        //'settings',
                        [
                            'class' => 'yii\grid\ActionColumn',
                            'header' => '操作',
                            'template' => '{audit}',
                            'buttons' => [
                                'audit' => function ($url, $model, $key) {
                                    $addonsurl = Url::to(['/addons/' . $model->name]);
                                    return  Html::a('<button class=" btn btn-block btn-primary btn-xs">进入模块</button> ', $addonsurl, ['title' => '进入模块']);
                                },
                            ],
                            'headerOptions' => ['width' => '80'],
                        ],
                        [
                            'class' => 'yii\grid\ActionColumn'

                        ],
                    ],
                ]); ?>


            </div>
        </div>
    </div>
</div>

<?php JSRegister::begin(['id' => 'pluginslist']); ?>
<script>
    $(function() {})
</script>
<?php JSRegister::end(); ?>